/*
 * zzllrr Mather
 * zzllrr@gmail
 * Released under MIT License
 */

wiki['Formula/Matrix/Inverse']=Kx(kbrA([
'A^{-1} = '+frac('A^*','|A|',''),
'(kA)^{-1}='+frac('A^{-1}','k','')+ ' 其中k≠0',
'(AB)^{-1} = B^{-1}A^{-1}',
piece([
    '(A^{-1})^T = (A^T)^{-1}',
    '(A^{-1})^* = (A^*)^{-1}',
    '(A^T)^* = (A^*)^T',
]),
'((A^T)^*)^{-1} = ((A^T)^{-1})^*','= ((A^{-1})^T)^* = ((A^{-1})^*)^T ','= ((A^*)^T)^{-1} = ((A^*)^{-1})^T',
])+
detail(ksc('(A^{-1}+B^{-1})^{-1}=B(A+B)^{-1}A'),
    kbrA(['证明：',
        Eq(['(A^{-1}+B^{-1})B(A+B)^{-1}A',
            'A^{-1}B(A+B)^{-1}A+(A+B)^{-1}A',
            'A^{-1}B(A+B)^{-1}A+A^{-1}A(A+B)^{-1}A',
            'A^{-1}(B+A)(A+B)^{-1}A',
            'A^{-1}A',
            'I'])
    ])
)+
ksc(
piece([
    '(I+AB)^{-1} =I-A(I+BA)^{-1}B',
    '(I-AB)^{-1} =I+A(I-BA)^{-1}B',
    '(I+BA)^{-1} =I-B(I+AB)^{-1}A',
    '(I-BA)^{-1} =I+B(I-AB)^{-1}A',
])
)+

detail(ksc('I+AB可逆⇔ I+BA可逆'), kbrA(['证明：',
    Eq(['(I+BA)(I-B(I+AB)^{-1}A)','I+BA-B(I+AB)^{-1}A-BAB(I+AB)^{-1}A','I+BA-B(I+AB)(I+AB)^{-1}A','I+BA-BA','I'])
]))+

detail(ksc('I-AB可逆⇔ I-BA可逆'), kbrA(['证明：',

    Eq(['(I-BA)(I+B(I-AB)^{-1}A)','I-BA+B(I-AB)^{-1}A-BAB(I-AB)^{-1}A','I-BA+B(I-AB)(I-AB)^{-1}A','I-BA+BA','I']),
    '用分块矩阵证明\\small ',
    zmtrx([['I','A'],['O','I']])+zmtrx([['I-AB','O'],['B','I']])+' = '+zmtrx([['I','O'],['B','I-BA']])+zmtrx([['I','A'],['O','I']]),
    '两边取行列式，化简得到','|I-AB|=|I-BA|','则I-AB，I-BA同时可逆或同不可逆',
    '类似地，',
    zmtrx([['I','A'],['O','I']])+zmtrx([['λI-AB','O'],['B','I']])+' = '+zmtrx([['I','O'],['B','λI-BA']])+zmtrx([['I','A'],['O','I']]),
    '两边取行列式，化简得到','|λI-AB|=|λI-BA|','则λI-AB，λI-BA同时可逆或同不可逆'
]))+
kbrA([
'|A^{-1}| = |A|^{-1}',
'r(A^{-1}) = r(A^*) = r(A)',

'常见算法：',
])+
detail('初等行变换：'+ksc('A|I → I|A^{-1}'), kbrA([

    kbox('Gauss-Jordan算法')+'\\small ',
    Eq([zmtrx([['a','b',1,0],['c','d',0,1]],'','c2'),
        zmtrx([['a','b',1,0],['ac','ad',0,'a']],'','c2'),
        zmtrx([['a','b',1,0],[0,'ad-bc','-c','a']],'','c2'),
        zmtrx([['a',0,frac('ad','ad-bc',''),'-'+frac('ab','ad-bc','')],[0,'ad-bc','-c','a']],'','c2'),
        zmtrx([[1,0,frac('d','ad-bc',''),'-'+frac('b','ad-bc','')],[0,'1','-'+frac('c','ad-bc',''),frac('a','ad-bc','')]],'','c2'),
        frac(1,'ad-bc','')+zmtrx([['d','-b'],['-c','a']])
        ],['第2行乘以a','第2行减去第1行的c倍','第1行减去第2行的b/(ad-bc)倍',['第1行除以a','第2行除以ad-bc'],'得到逆矩阵'],'','→'),
    

]))+

detail('伴随矩阵法：'+ksc('A^{-1} = '+frac('A^*','|A|',''),''))+

detail('分块矩阵：', kbrA([
    kxf('diag')+'^{-1}(A_i) = '+kxf('diag')+'(A_i^{-1})',
    '~',

    piece([
    zmtrx([['O','A'],['B','C']])+'^{-1} = '+zmtrx([['-B^{-1}CA^{-1}','B^{-1}'],['A^{-1}','O']],'','rc : .'),'~',
        zmtrx([['O','A'],['B','I']])+'^{-1} = '+zmtrx([['-B^{-1}A^{-1}','B^{-1}'],['A^{-1}','O']],'','rc : .'),'~',
            zmtrx([['O','I'],['I','C']])+'^{-1} = '+zmtrx([['-C','I'],['I','O']]),
        ]),
    '~',

    piece([
    zmtrx([['A','O'],['C','B']])+'^{-1} = '+zmtrx([['A^{-1}','O'],['-B^{-1}CA^{-1}','B^{-1}']],'1.5','rc : .'),'~',
        zmtrx([['A','O'],['I','B']])+'^{-1} = '+zmtrx([['A^{-1}','O'],['-B^{-1}A^{-1}','B^{-1}']],'1.5','rc : .'),'~',
            zmtrx([['I','O'],['C','I']])+'^{-1} = '+zmtrx([['I','O'],['-C','I']]),
        ]),
    '~',

    piece([
    zmtrx([['A','C'],['O','B']])+'^{-1} = '+zmtrx([['A^{-1}','-A^{-1}CB^{-1}'],['O','B^{-1}']],'','rc : .'),'~',
        zmtrx([['A','I'],['O','B']])+'^{-1} = '+zmtrx([['A^{-1}','-A^{-1}B^{-1}'],['O','B^{-1}']],'','rc : .'),'~',
            zmtrx([['I','C'],['O','I']])+'^{-1} = '+zmtrx([['I','-C'],['O','I']]),
        ]),
    '~',
    
    piece([
    zmtrx([['C','A'],['B','O']])+'^{-1} = '+zmtrx([['O','B^{-1}'],['A^{-1}','-A^{-1}CB^{-1}']],'','rc : .'),'~',
        zmtrx([['I','A'],['B','O']])+'^{-1} = '+zmtrx([['O','B^{-1}'],['A^{-1}','-A^{-1}B^{-1}']],'','rc : .'),'~',
            zmtrx([['C','I'],['I','O']])+'^{-1} = '+zmtrx([['O','I'],['I','-C']]),
        ]),
    '~',
    
    piece([
    zmtrx([['A','O'],['O','B']])+'^{-1} = '+zmtrx([['A^{-1}','O'],['O','B^{-1}']]),'~',
    zmtrx([['O','A'],['B','O']])+'^{-1} = '+zmtrx([['O','B^{-1}'],['A^{-1}','O']]),
        ]),
    '~',
])+detail('规律：',kbrA([
    'A、B分别求逆，C替换为-C，',
    '并用A、B除（与C同行左除，同列右除）',
    '0在副对角线（特例：准对角阵），分块方法不变',
    '0在主对角线，分块方法变化，',
    '主（副）对角线方向分块对调',
])))+

detail('特征多项式法：', kbrA([
    'f(A)=(A-λ_1I)(A-λ_2I)⋯(A-λ_nI)=0',
    '⇒ A^{-1} = '+frac('f-|-A|','-|-A|x','')+'(A) = '+frac('1-f/|-A|','x','')+'(A)',
]))+
detail('凑数法：',kbrA([
    'f(A) = 0  ⇔ (A+kI)(A+?I) = tI ',
    '⇔ (A+kI)^{-1}='+frac('A+?I','t',''),


]))

);